package com.example.fengyungo.service.impl;

import com.example.fengyungo.constant.DriverVerifyConstant;
import com.example.fengyungo.dao.DriverVerifyDao;
import com.example.fengyungo.domain.pojo.DriverVerify;
import com.example.fengyungo.service.DriverVerifyService;
import com.example.fengyungo.util.CommonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DriverVerifyServiceImpl implements DriverVerifyService {

    @Autowired
    private DriverVerifyDao driverVerifyDao;

    /**
     * 添加司机认证材料
     *
     * @param driverVerify DriverVerify
     * @return Integer
     */
    @Override
    public Integer addDriverVerify(DriverVerify driverVerify) {
        String time = CommonUtils.getNowTime();
        driverVerify.setTime(time);
        driverVerify.setStatus(DriverVerifyConstant.NOT_HANDLED);
        Integer res = driverVerifyDao.addDriverVerify(driverVerify);
        return res;
    }

    /**
     * 获取所有司机证明材料信息，按时间先后排序
     *
     * @return 所有司机证明材料信息
     */
    @Override
    public List<DriverVerify> getAllDriverVerify() {
        List<DriverVerify> allDriverVerify = driverVerifyDao.getAllDriverVerify();
        return allDriverVerify;
    }

    /**
     * 获取所有未处理的司机证明材料信息，按时间先后排序
     *
     * @return 所有司机证明材料信息
     */
    @Override
    public List<DriverVerify> getAllDriverVerifyNotHandled() {
        List<DriverVerify> allDriverVerifyNotHandled = driverVerifyDao.getAllDriverVerifyNotHandled();
        return allDriverVerifyNotHandled;
    }

    /**
     * 根据id修改司机认证信息状态
     *
     * @param driverId  驾驶员id
     * @param status    状态
     * @return Integer
     */
    @Override
    public Integer updateDriverVerifyStatusById(String driverId, Integer status) {
        DriverVerify driverVerify = new DriverVerify();
        driverVerify.setDriverId(driverId);
        driverVerify.setStatus(status);
        Integer res = driverVerifyDao.updateDriverVerifyById(driverVerify);
        return res;
    }

    /**
     * 根据司机id获取司机姓名
     *
     * @param driverId String
     * @return String
     */
    @Override
    public String getDriverNameById(String driverId) {
        return driverVerifyDao.getDriverNameById(driverId);
    }
}
